<?php

class DBAccess
{
    var $link;
    
    function getLink()
    {
        return $this->link;
    }
    
    function connect()
    {
        $this->link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Ket noi khong thanh cong");
        mysql_select_db(DB_DATABASE, $this->link) or die("Khong tim thay csdl");
    }
    
    function disconnect()
    {
        mysql_close($this->link);
    }
    
    function executeQuery($sqlString)
    {
        $this->connect();
        $sql = 'set names "utf8"';
        @ mysql_query($sql);
        $list = @ mysql_query($sqlString);
        $this->disconnect();
        return $list;
    }
    
    function executeNonQuery($sqlString)
    {
        $this->connect();
        $sql = 'set names "utf8"';
        @ mysql_query($sql);
        mysql_query($sqlString);
        if(mysql_affected_rows($this->link) > 0)
        {   
            $this->disconnect();
            return true;
        }
        else    
        {   
            $this->disconnect();
            return false;
        }
    }
}
